package com.example.interpreter2;

public class CommandNode implements Node {

    private Node node;

    @Override
    public void interpret(Context context) {
        if (context.getCurrentToken().equals("LOOP")) {
            LoopCommandNode node = new LoopCommandNode();
            node.interpret(context);
            this.node = node;
        } else {
            PrimitiveNode node = new PrimitiveNode();
            node.interpret(context);
            this.node = node;
        }
    }

    @Override
    public void execute() {
        this.node.execute();
    }
    
}
